﻿using System;
using System.Threading;

namespace Basics107b
{
    /// <summary>
    /// Author: Mr. Jin Vincent N. Necesario
    /// Level: Beginner
    /// Problem: Write a program that inputs one number consisting of five digits from the user,
    /// seperates the number into individual digits and prints the digits separated from one another
    /// by one space/tab each and reverse the number.
    /// Test Case: 
    /// Input: 42339
    /// Output: 
    /// 4 2 3 3 9
    /// 9 3 3 2 4
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            int number = 0;
            
            bool valid = false;
            
            string result = string.Empty;

            while (!valid)
            {
                Console.Clear();

                Console.WriteLine("Enter a number consisting 5 digits");

                if (int.TryParse(Console.ReadLine().Substring(0, 5), out number))
                {
                    valid = true;
                }
                else 
                {
                    Console.WriteLine("Oops! Something went wrong. Please try again!!..");
                    Thread.Sleep(500);
                }
            }

            while (number!=0)
            {
                result += string.Format("{0}", (number % 10));
                
                number = number / 10;
            }

            int len = result.Length;

            for (int i = (len-1); i >= 0; i--)
            {
                Console.Write("{0}\t", result[i]);
            }

            Console.WriteLine("");
            
            for (int i = 0; i < len; i++)
            {
                Console.Write("{0}\t", result[i]);
            }
            
            Console.ReadKey();

        }
    }
}
